<?php
include "SMS_NEW/TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

class Sms
{

    private $client = null;

    private $appKey = '23443178';

    private $secretKey = 'f68665a63d0c7c976181531752779c7a';

    /**
     * 发送短信,所有参数都必须是string
     * 
     * @param string $mobile
     *            手机号码
     * @param string $type
     *            发送类型(1:注册 2:忘记密码 3:提现)
     * @param string $code
     *            验证码
     * @return json $res 返回结果
     */
    public function sendMsg($mobile, $code)
    {
        $c = new TopClient();
        $c->appkey = $this->appKey;
        $c->secretKey = $this->secretKey;
        $req = new AlibabaAliqinFcSmsNumSendRequest();
        // $req->setExtend("1234");//uid,可以是任何需要回掉参数
        $req->setSmsType("normal");
        $req->setSmsFreeSignName("客牛科技");
        $req->setSmsParam('{"code":"' . $code . '","product":"欢迎注册客牛"}');
        $req->setRecNum("{$mobile}");
        $req->setSmsTemplateCode("SMS_13720542"); // 查阅阿里大于后台审核通过的模板均可使用,可通过配置$type使用不同模板
        return $c->execute($req);
    }
}

